import { http } from "@/utils/http";
import { baseUrlApi } from "./utils";



/** 分页获取图书 */
export const getBooks = (params?: object) => {
  return http.request<any>("get", baseUrlApi("book"), { params });
};

/** 添加图书 */
export const addBook = (data?: object) => {
  return http.request<any>("post", baseUrlApi("book"), { data });
};

/** 编辑图书 */
export const editBook = (data?: any) => {
  return http.request<any>("put", baseUrlApi("book/" + data.id), { data });
};

/** 删除图书 */
export const deleteBook = (id?: any) => {
  return http.request<any>("delete", baseUrlApi("book/" + id));
};

/** 分页获取作者 */
export const getAuthor = (params?: object) => {
  return http.request<any>("get", baseUrlApi("author"), { params });
};

/** 添加作者 */
export const addAuthor = (data?: object) => {
  return http.request<any>("post", baseUrlApi("author"), { data });
};

/** 编辑作者 */
export const editAuthor = (data?: any) => {
  return http.request<any>("put", baseUrlApi("author/" + data.id), { data });
};

/** 删除作者 */ 
export const deleteAuthor = (id?: any) => {
  return http.request<any>("delete", baseUrlApi("author/" + id));
};

/** 获取出版社 */
export const getPublish = (params?: object) => {
  return http.request<any>("get", baseUrlApi("publish"), { params });
};

/** 添加出版社 */
export const addPublish = (data?: object) => {
  return http.request<any>("post", baseUrlApi("publish"), { data });
};

/** 编辑出版社 */
export const editPublish = (data?: any) => {
  return http.request<any>("put", baseUrlApi("publish/" + data.id), { data });
};

/** 编辑出版社 */
export const deletePublish = (id?: any) => {
  return http.request<any>("delete", baseUrlApi("publish/" + id));
};

/** 获取ecahrt数据 */
export const getData = () => {
  return http.request<any>("get", baseUrlApi("getdata"));
};